/**
 * Created by yaling.he on 2015/11/17.
 */


//供应商管理页面上点击删除按钮弹出删除框(providerList.jsp)
$(function () {
    $('.removeProvider').click(function () {
        $('.zhezhao').css('display', 'block');
        $('#removeProv').fadeIn();
        //获取当前行的provider主键id
        var id = $(this).attr("id");
        $(".removerChid").attr("id", id);
    });
});

/*确认删除供应商操作*/
$(function () {
    $('#yesProvider').click(function () {
        $('.zhezhao').css('display', 'none');
        $('#removeUse').fadeOut();
        var id = $(".removerChid").attr("id");
        // alert("id" + id);
        $.post(
            ctx + "/provider/deleteProviderById",
            {"id": id},
            function (result) {
                //alert("result" + result);
                if (result == 1) {
                    alert("删除成功！");
                    location.href = ctx + "/provider/providerList";
                } else if (result == 2) {
                    alert("该供应商存在未付款的订单，不能执行删除操作！");
                    $('.remove').css("display", "none");
                } else {
                    alert("删除失败！");
                    $('.remove').css("display", "none");
                }

            }, "json"
        );
    });
});


$(function () {
    $('#no').click(function () {
        $('.zhezhao').css('display', 'none');
        $('#removeProv').fadeOut();
    });
});


//订单管理页面上点击删除按钮弹出删除框(billList.jsp)
$(function () {
    $('.removeBill').click(function () {
        $('.zhezhao').css('display', 'block');
        $('#removeBi').fadeIn();
        //获取当前行的bill主键id
        var id = $(this).attr("id");
        $(".removerChid").attr("id", id);
    });
});

/*确认删除订单操作*/
$(function () {
    $('#yesBill').click(function () {
        $('.zhezhao').css('display', 'none');
        $('#removeBi').fadeOut();
        var id = $(".removerChid").attr("id");
        $.post(
            ctx + "/bill/deleteBillById",
            {"id": id},
            function (result) {
                if (result) {
                    alert("删除成功！")
                    location.href = ctx + "/bill/billList";
                } else {
                    alert("删除失败！");
                }

            }
        );
    });
});

$(function () {
    $('#no').click(function () {
        $('.zhezhao').css('display', 'none');
        $('#removeBi').fadeOut();
    });
});

//用户管理页面上点击删除按钮弹出删除框(userList.jsp)
$(function () {
    $('.removeUser').click(function () {
        //样式的处理
        $('.zhezhao').css('display', 'block');
        $('#removeUse').fadeIn();
        //获取当前行的user主键id
        var id = $(this).attr("id");
        $(".removerChid").attr("id", id);

    });
});

/*确认删除用户操作*/
$(function () {
    $('#yesUser').click(function () {
        $('.zhezhao').css('display', 'none');
        $('#removeUse').fadeOut();
        var id = $(".removerChid").attr("id");
        $.post(
            ctx + "/user/deleteUserById",
            {"id": id},
            function (result) {
                // alert(result);
                if (result) {
                    alert("删除成功！")
                    location.href = ctx + "/user/userList";
                } else {
                    alert("删除失败！");
                }

            }
        );
    });
});

$(function () {
    $('#no').click(function () {
        $('.zhezhao').css('display', 'none');
        $('#removeUse').fadeOut();
    });
});
